<?php

namespace IDock\Insurance\LIHI\Request;

use IDock\Insurance\LIHI\Response\NonCarProductListResponse;
use IDock\Visitor\NonCar\NonCarProductListVisitor;

class NonCarProductListRequest extends AllLIHIRequest
{

    protected $urlTip = '非车产品列表';

    public $route = 'cpservice/queryPlans';

    protected $response = NonCarProductListResponse::class;

    public $hasE200 = true;

    /*** @var NonCarProductListVisitor $visitor */
    protected $visitor;

    public function generate(): array
    {
        $this->agreementCode = $this->visitor->argc['agreementNo'] ?? '';
        $this->recordCode = $this->visitor->argc['recordCode'] ?? '';

        $arr = [
            'agentCode' => $this->agreementCode,
            'agreementCode' => $this->agreementCode,
            'products' => [
                "2724",
                "3105"
            ],//用户代码
            'paraMap' => [
                "00005" => "1",
                "00006" => "1",
                "00007" => "2",
                "00001" => $this->visitor->seats ?: '5',
                "00002" => "365",
                "00003" => "26",
                "00008" => "LBN003",
                "00041" => "0"
            ],
            "kindCodeList" => [
                "BZ",

                //"E200", //车损
            ],
            "tprpTmainDto" => [
                "combineFlag" => "COMBINE",
                "proposalNo" => "",
                "mtplProposalNo" => "",
                "salerNumber" => "",
                "salerName" => "",
                "startDate" => date('y-m-d H:i:s', strtotime("+1 day")),
                "startHour" => "00",
                "endDate" => date('y-m-d H:i:s', strtotime("+1 day +1 year")),
                "endHour" => "24",
                "mtplStartDate" => date('y-m-d H:i:s', strtotime("+1 day")),
                "mtplStartHour" => "0",
                "mtplEndDate" => date('y-m-d H:i:s', strtotime("+1 day +1 year")),
                "mtplEndHour" => "24",
                "newEnergyFlag" => 0,
                "callBackUrl" => "https://a.bxt.freeradio.cn//insuranceDockAsy/LIHI",
            ],
            "tprpTitemCarDto" => [
                "runAreaCode" => "10",
                "carInsuredRelation" => "3",
                "licenseKindCode" => "02",
                "licenseNo" => "川GSR720",
                "carKindCode" => "A0",
                "exhaustScale" => 2.487,
                "tonCount" => "0",
                "seatCount" => "7",
                "useNatureCode" => "8A",
                "engineNo" => "LE60873",
                "vinNo" => "LVGDD4A47PG088431",
                "modelCode" => "FTA7795AIO",
                "whethelicenses" => "1",
                "whethercar" => "0",
                "fuelType" => 4,
                "enrollDate" => "2023-03-16",
                "purchasePrice" => 336279,
                "vehicleCategoryCode" => "K33",
                "vehicleModel" => "丰田GTM6520SHEVM混合动力多用途乘用车",
                "chgOwnerFlag" => "0",
                "mtplChgOwnerFlag" => "",
                "poWeight" => "2090",
                "loanVehicleFlag" => "0",
                "vehicleBrand" => "丰田",
                "countryCode" => "合资车"
            ],

            "tprptCarOwnerDto" => [
                "name" => "王晓",
                "idType" => "01",
                "idNo" => "140429198308251618",
                "cellPhoneNo" => "18563541254",
                "address" => "天津市河西区三水道桂江里30门608号",
                "email" => "18318327016@qq.com",
                "gental" => "1",
                "effectedDate" => "2025-04-08",
                "expiredDate" => "2099-12-31",
                "natureOfRole" => "1"
            ],
            "tprptApplicantDto" => [
                "name" => "王晓",
                "idType" => "01",
                "idNo" => "140429198308251618",
                "cellPhoneNo" => "18563541254",
                "address" => "天津市河西区三水道桂江里30门608号",
                "email" => "18318327016@qq.com",
                "gental" => "1",
                "effectedDate" => "2025-04-08",
                "expiredDate" => "2099-12-31",
                "natureOfRole" => "1"
            ],
            "tprptInsuredDto" => [
                "name" => "王晓",
                "idType" => "01",
                "idNo" => "140429198308251618",
                "cellPhoneNo" => "18563541254",
                "address" => "天津市河西区三水道桂江里30门608号",
                "email" => "18318327016@qq.com",
                "gental" => "1",
                "effectedDate" => "2025-04-08",
                "expiredDate" => "2099-12-31",
                "natureOfRole" => "1"
            ],
            "tprpTitemKindListDto" => [
                [
                    "itemKindNo" => "1",
                    "kindCodeMain" => "E200",
                    "kindNameMain" => "机动车损失保险",
                    "quantityMain" => "0",
                    "amountMain" => "200085.9"
                ],
                [
                    "itemKindNo" => "2",
                    "kindCodeMain" => "E600",
                    "kindNameMain" => "机动车第三者责任保险",
                    "quantityMain" => "0",
                    "amountMain" => "2000000"
                ],
                [
                    "itemKindNo" => "3",
                    "kindCodeMain" => "E701",
                    "kindNameMain" => "机动车车上人员责任保险（司机）",
                    "quantityMain" => "0",
                    "amountMain" => "10000"
                ],
                [
                    "itemKindNo" => "4",
                    "kindCodeMain" => "E702",
                    "kindNameMain" => "机动车车上人员责任保险（乘客）",
                    "quantityMain" => "6",
                    "amountMain" => "60000",
                    "unitAmountMain" => "10000"
                ]
            ],
            "prpTcarshipTaxDto" => [
                "taxpayerName" => "王晓",
                "taxPayerIdentificationCode" => "140429198308251618",
                "taxConditionCode" => "T",
                "taxDocumentNumber" => "",
                "deductionDocumentNumber" => ""
            ]
        ];

        if ($this->hasE200) {
            $arr['kindCodeList'][] = 'E200';

            $arr['kindCodeList'][] = "E600";
            $arr['kindCodeList'][] = "E701";
            $arr['kindCodeList'][] = "E003";
            $arr['kindCodeList'][] = "E004";
            $arr['kindCodeList'][] = "E006";
        }

        return $arr;
    }
}
